package com.example.yoho.mvp.view.adapter;

import android.annotation.SuppressLint;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.yoho.R;
import com.example.yoho.domain.Domain_Url;
import com.example.yoho.mvp.model.entity.StrlloListEntity;
import com.example.yoho.utils.MyGlide;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class MyStrlloAdapter extends BaseQuickAdapter<StrlloListEntity.ValuesBean, BaseViewHolder> {
    public MyStrlloAdapter(int layoutResId, @Nullable List<StrlloListEntity.ValuesBean> data) {
        super(layoutResId, data);
    }

    @SuppressLint("SimpleDateFormat")
    @Override
    protected void convert(BaseViewHolder helper, StrlloListEntity.ValuesBean item) {
        ImageView imageView=helper.getView(R.id.strllo_image);
        TextView textView_text=helper.getView(R.id.strllo_text);
        TextView textView_title=helper.getView(R.id.strllo_title);
        TextView textView_time=helper.getView(R.id.strllo_time);
        TextView textView_num=helper.getView(R.id.strllo_num);

        LinearLayout linearLayout=helper.getView(R.id.strllo_linl);
        textView_text.setText(item.getSee_edt_name());
        textView_title.setText(item.getSee_news_title());
        String see_news_time = item.getSee_news_time();
        long integer = Integer.valueOf(see_news_time);


        Date date = new Date(integer*1000);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM月dd日HH:mm");
        String format = simpleDateFormat.format(date);
        textView_time.setText(format);
        textView_num.setText(item.getSee_news_num());

        linearLayout.removeAllViews();
        for (int i = 0; i < 5; i++) {
            View inflate = LayoutInflater.from(mContext).inflate(R.layout.strllo_view, null);
            linearLayout.addView(inflate);
        }
        MyGlide.GlideFor(mContext, Domain_Url.IMAGE_URL+item.getSee_news_img(),imageView);


    }
}
